;(function(){
  'use strict';
  angular.module('services.omdisplay.upayQM',[])
  .factory('UpayQMServer', upayQMServer);

  function upayQMServer(){
    var bank = [];
    return {
      initDate : initDate,
      setBank : setBank,
      getBank : getBank
    };

    function initDate(timeType){
      var now = new Date();
      var date = {};
      var year = now.getFullYear();
      var month = now.getMonth();
      var day = now.getDate()-1;
      switch(timeType){
        case '3':
          date.startTime = new Date(year,month);
          date.endTime = new Date(year,month);
          break;
        case '5':
          date.startTime = year;
          date.endTime = year;
          break;
        default:
          date.startTime = new Date(year,month,day);
          date.endTime = new Date(year,month,day);
      }
      return date;
    }
    function setBank(Bank){
      bank = Bank;
      return bank;
    }

    function getBank(){
      var bankArr = [];
      if(is.array(bank)){
        bankArr = bank.map(function(item){
          return {agencyName:item.bankName,agencyCode:item.bankCode};
        });
      }
      return bankArr;
    }
  }

})();